﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using ScenarioFramework.WorkflowEngine.Database.WorkflowProcesses;
using ScenarioFramework.WorkflowEngine.DataBase;

namespace ScenarioFramework.Portal.SF.Reports.UserControls
{
    public partial class BAMKPI : System.Web.UI.UserControl
    {
        #region Attributes to choise Statement and filter
        public string Statement = string.Empty;
        public string Id = string.Empty;
        public string Name = string.Empty;
        public string Value = string.Empty;
        public int Elapsed = 0;
        #endregion

        KPI kpi = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            kpi = new KPI();
            if ( Request.QueryString["Id"] !=null )
                   kpi.Id = Request.QueryString["Id"];
            if ( Request.QueryString["Name"] !=null )
                   kpi.Name = Request.QueryString["Name"];
            if ( Request.QueryString["Value"] !=null )
                   kpi.Value = Request.QueryString["Value"];
            if ( Request.QueryString["Elapsed"] !=null )
                   kpi.Elapsed = Int32.Parse (Request.QueryString["Elapsed"]);
            if ( Request.QueryString["Statement"] !=null )
                  Statement = Request.QueryString["Statement"];

            if (Statement.CompareTo(String.Empty) == 0)
                this.GridView1.DataSource = Helpers.KPIHelper().SelectAllKPIs();
            else
                this.GridView1.DataSource = Helpers.KPIHelper().Select(Statement, kpi);

            this.GridView1.DataBind();
        }

    }
}